<template>
  <div class="dashboard-container">
    <div class="app-container">
      <el-card>
        <el-tabs>
          <!-- 放置页签 -->
          <el-tab-pane label="角色管理">
            <!-- 新增角色按钮 -->
            <el-row style="height:60px">
              <el-button
                icon="el-icon-plus"
                size="small"
                type="primary"
              >新增角色</el-button>
            </el-row>
            <!-- 表格 -->
            <el-table border="" :data="list">
              <el-table-column label="序号" type="index" width="120" />
              <el-table-column label="角色名称" prop="name" width="240" />
              <el-table-column label="描述" prop="description" />
              <el-table-column label="操作">
                <el-button size="small" type="success">分配权限</el-button>
                <el-button size="small" type="primary">编辑</el-button>
                <el-button size="small" type="danger" @click="del(data)">删除</el-button>
              </el-table-column>
            </el-table>
            <!-- 分页组件 -->
            <el-row type="flex" justify="center" align="middle" style="height: 60px">
              <!-- 分页组件 -->
              <el-pagination
                :current-page="pages.page"
                :page-size="pages.pagesize"
                :total="pages.total"
                layout="prev, pager, next"
                @current-change="changePage"
              />
            </el-row>
          </el-tab-pane>
          <el-tab-pane label="公司信息">
            <el-alert
              title="对公司名称、公司地址、营业执照、公司地区的更新，将使得公司资料被重新审核，请谨慎修改"
              type="info"
              show-icon
              :closable="false"
            />
            <el-form label-width="120px" style="margin-top:50px">
              <el-form-item label="公司名称">
                <el-input v-model="formData.name" disabledstyle="width:400px" />
              </el-form-item>
              <el-form-item label="公司地址">
                <el-input v-model="formData.companyAddress" disabled style="width:400px" />
              </el-form-item>
              <el-form-item label="邮箱">
                <el-input v-model="formData.mailbox" disabled style="width:400px" />
              </el-form-item>
              <el-form-item label="备注">
                <el-input v-model="formData.remarks" type="textarea" :rows="3" disabled style="width:400px" />
              </el-form-item>
            </el-form>
          </el-tab-pane>

        </el-tabs>
      </el-card>
    </div>
  </div>

</template>

<script>
import { getcompanyInfo, getsettingList, delpeople } from '@/api/setting'
import { mapGetters } from 'vuex'
export default {
  data() {
    return {
      formData: {},
      list: [],
      pages: {
        page: 1,
        pagesize: 2,
        total: 0 // 记录总数
      }
    }
  },
  computed: {
    ...mapGetters(['companyId'])
  },

  created() {
    this.getCompanyInfo()
    this.getsettingList()
  },
  methods: {
    // async init() {
    //   console.log(this.companyId)
    //   this.formData = await getcomponyInfo(this.companyId)
    //   // // console.log(this.formData)
    //   // this.list = await getsettingList()
    //   // console.log(this.list)
    // }
    async getCompanyInfo() {
      // console.log('faf' + this.companyId)
      this.formData = await getcompanyInfo(this.companyId)
      console.log(this.formData)
    },
    async getsettingList() {
      // console.log('faf' + this.companyId)

      const { rows, total } = await getsettingList(this.pages)
      this.list = rows
      this.pages.total = total
      console.log(this.list[0])
    },
    changePage(newPage) {
      // newPage是当前点击的页码
      this.pages.page = newPage // 将当前页码赋值给当前的最新页码
      this.getsettingList(this.pages)
    },
    async del(id) {
      console.log(id)
      await delpeople(id)
    }
  }
}
</script>
<style lang='less' scoped>

</style>
